package cn.hls.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import cn.hls.dao.HandCarDao;
import cn.hls.entity.HandCar;
import cn.hls.entity.vo.PageInfo;
import cn.hls.service.HandCarService;

 
/**
 *@fileName: HandCarDaoImpl.java
 *@package: cn.christ.dao.impl
 *@Description:  车辆基本信息数据接口实现类
 *@author: yinghui.zhang
 *@email: uuhui@163.com
 *@date: 2015-7-18
 */
@Component("handCarService")
public class HandCarServiceBean extends BaseServiceBean<HandCar> implements HandCarService {
	@Resource(name="handCarDao")
	private HandCarDao dao;
	@Override
	public PageInfo<HandCar> loadHandCarInfo(HandCar entity, PageInfo<HandCar> page) throws Exception {
		return dao.loadHandCarInfo(entity, page);
	}
	 
	@Override
		public boolean exists(HandCar entity)throws Exception{
			return dao.exists(entity);
	}

	@Override
	public void delete(Object entityId) throws Exception {
		dao.delete(entityId);
	}
	@Override
	public List<HandCar> loadHandCarList(HandCar entity) throws Exception {
		return dao.loadHandCarList(entity);
	}
	
	public HandCar loadHandCarByLicenseNum(String licenseNum)throws Exception{
		return dao.loadHandCarByLicenseNum(licenseNum);
	}
	 
	@Override
	public boolean update(HandCar entity) throws Exception {
		HandCar tempEntity=super.find(entity.getId());
		Date createTime=tempEntity.getCreateTime();
		Date updateTime=new Date();
		BeanUtils.copyProperties(entity, tempEntity);
		//重新设置对象的生成日期
		tempEntity.setCreateTime(createTime);
		//设置对象的更新时间
		tempEntity.setUpdateTime(updateTime);
		return super.update(tempEntity);
	}
}
